// 快慢指针
// 快指针：跳过重复数，记录下一个前面没有重复数的节点位置
// 慢指针：标记重复数组出现起点，根据链表特性，负责与下一个快指针连接

var deleteDuplicates = function (head) {
  let dummy = new listNode(-1);
  dummy.next = head;
  let fast = dummy.next;
  let slow = dummy;
  while (fast) {
    while (fast.next && fast.val === fast.next.val) {
      fast = fast.next;
    }
    if (slow.next === fast) {
      slow = slow.next;
    } else {
      slow.next = fast.next;
    }
    fast = fast.next;
  }
  return dummy.next;
};
